#ifndef EVENTS_H
#define EVENTS_H

/* Copyright (C) 2011 Riccardo Marson

   This file is part of OpenPool, an open-source game of pool. 

   Permission is hereby granted, free of charge, to any person obtaining a
   copy of this software and associated documentation files (the "Software"),
   to deal in the Software without restriction, including without limitation
   the rights to use, copy, modify, merge, publish, distribute, sublicense,
   and/or sell copies of the Software, and to permit persons to whom the
   Software is furnished to do so, subject to the following conditions:

   The above copyright notice and this permission notice shall be included
   in all copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
   RICCARDO MARSON BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
   AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

  See Readme.rtf for further information.
  
*/

#include <string>
#include <list>
#include <utility>
#include <set>
#include <map>

#include "interfaces.h"

class CBaseEvent : public IEvent
{
public:

    CBaseEvent(eEventType eventType);
    virtual ~CBaseEvent();
    virtual eEventType getEventType();
    virtual string getEventTypeStr();

protected:

    eEventType mEventType;

};


class CKeyEvent : public CBaseEvent
{
public:

    CKeyEvent(int whichKey);
    virtual ~CKeyEvent();

    int key();

private:

    int mKey;
};

class CBallMovedEvent : public CBaseEvent
{
public:

    CBallMovedEvent(eObjectID id, CVector3 pos, CVector3 heading, CVector3 rotAxis, float rotAngle);
    virtual ~CBallMovedEvent();

    eObjectID id();
    CVector3 position();
    CVector3 heading();
    CVector3 rotationAxis();
    float rotationAngle();

private:

    eObjectID mBallID;
    CVector3 mNewPosition;
    CVector3 mNewHeading;
    CVector3 mNewRotationAxis;
    float mNewRotationAngle;
};

class CCameraMovedEvent : public CBaseEvent
{
public:

    CCameraMovedEvent(CVector3 pos);
    virtual ~CCameraMovedEvent();

    CVector3 position();

private:

    CVector3 mNewPosition;
};

class CTableCollisionEvent : public CBaseEvent
{
public:

    CTableCollisionEvent(eObjectID id, CVector3 point, CVector3 normal);
    virtual ~CTableCollisionEvent();

    eObjectID id();
    CVector3 collisionPoint();
    CVector3 collisionNormal();

private:

    eObjectID mBallID;
    CVector3 mCollisionPoint;
    CVector3 mCollisionNormal;
};

class CBallCollisionEvent : public CBaseEvent
{
public:

    CBallCollisionEvent(eObjectID id1, eObjectID id2, CVector3 point, CVector3 normal);
    virtual ~CBallCollisionEvent();

    eObjectID id1();
    eObjectID id2();
    CVector3 collisionPoint();
    CVector3 collisionNormal();

private:

    eObjectID mBallID_1;
    eObjectID mBallID_2;
    CVector3 mCollisionPoint;
    CVector3 mCollisionNormal;
};

class CCueBallLaunchedEvent : public CBaseEvent
{
public:
    CCueBallLaunchedEvent(CVector3 hitPosition, CVector3 newVelocity);
    virtual ~CCueBallLaunchedEvent();

    CVector3 position();
    CVector3 velocity();

private:
    CVector3 mNewVelocity;
    CVector3 mHitPosition;

};

class CBallPocketedEvent : public CBaseEvent
{
public:
    CBallPocketedEvent(eObjectID id, CVector3 position, int currentScore, unsigned int ballsRemaining);
    virtual ~CBallPocketedEvent();

    CVector3 position();
    eObjectID id();
    int score();
    int ballsLeft();

private:

    CVector3 mPosition;
    eObjectID mID;
    int mScore;
    unsigned int mBallsLeft;

};

class CCueBallPocketedEvent : public CBaseEvent
{
public:
    CCueBallPocketedEvent(CVector3 initPosition, int currentScore, unsigned int ballsRemaining);
    virtual ~CCueBallPocketedEvent();

    CVector3 position();
    int score();
    int ballsLeft();


private:
    CVector3 mInitialPosition;
    int mScore;
    unsigned int mBallsLeft;

};

class CGameEndedEvent : public CBaseEvent
{
public:
    CGameEndedEvent(bool won);
    virtual ~CGameEndedEvent();

    bool gameIsWon();

private:
    bool mGameIsWon;

};

#endif // EVENTS_H
